#include <baker/Ray.h>
#include <unittest++/UnitTest++.h>

using namespace baker;

SUITE( TestRay2 )
{
    TEST( sizeof )
    {
        CHECK_EQUAL( sizeof( Ray2 ), sizeof( float ) * 4 );
    }
}

SUITE( TestRay3 )
{
    TEST( sizeof )
    {
        CHECK_EQUAL( sizeof( Ray3 ), sizeof( float ) * 6 );
    }

    TEST( getPoint )
    {
        const Ray3 ray( Vec3( 0, 1, 0 ), Vec3( 0, 0, 1 ) );

        CHECK( ray.getPoint( 2.0 ) == Vec3( 0, 1, 2 ) );
    }

    TEST( project )
    {
        const Ray3 ray( Vec3( 0, 1, 0 ), Vec3( 0, 0, 1 ) );

        CHECK_CLOSE( ray.project( Vec3( 0, 1, 2 ) ), 2.0, EPSILON );

        CHECK_CLOSE( ray.project( Vec3(-1, 1, 2 ) ), 2.0, EPSILON );

        CHECK_CLOSE( ray.project( Vec3( 1, 1, 2 ) ), 2.0, EPSILON );
    }

    TEST( dist )
    {
        const Ray3 ray( Vec3( 0, 1, 0 ), Vec3( 0, 0, 1 ) );

        CHECK_CLOSE( ray.dist( Vec3( 0, 1, 2 ) ), 0.0, EPSILON );

        CHECK_CLOSE( ray.dist( Vec3(-2, 1, 2 ) ), 2.0, EPSILON );

        CHECK_CLOSE( ray.dist( Vec3( 2, 1, 2 ) ), 2.0, EPSILON );
    }
}
